/**
 * @Author: Liu, Yunfeng
 * @DateTime: 2021/8/10 21:27
 * @Description: TODO
 */
public class numberOfArithmeticSlices {
    public int numberOfArithmeticSlices(int[] nums) {
        int length = nums.length;
        if(length<3){
            return 0;
        }
        int answer = 0;
        int d = nums[1]-nums[0];
        int current = 0;
        for(int i = 2; i<length; i++){
            int t = nums[i]-nums[i-1];
            if(t == d){
                current++;
            }else{
                d = t;
                current = 0;
            }
            answer+=current;
        }
        return answer;
    }
}
